|
|
|
|
|
|
|
Listing A.1 opens a database and then displays several data tables on the screen. This same script could perform any valid SQL statement and show the results on the screen for the user to review or edit. |
|
|
|
|
|
|
|
|
The advantage of generating database layouts using SQL-VB5 is that you have some documentation on the database structure that you can refer to in the future. You can also use SQL-VB5 to generate test SELECT queries and other SQL statements before you put them into your Visual Basic programs. Finally, SQL-VB5 is an excellent tool for exploring SQL and your databases. |
|
|
|
|
|
|
|
|
Before jumping into code mode, let's lay out some general design parameters for the SQL-VB5 project. SQL-VB5 should be able to do the following: |
|
|
|
|
|
|
|
|
· Open an ASCII file that contains valid SQL script statements. |
|
|
|
|
|
|
|
|
· Process the open file sequentially and perform all SQL statements in the file, including all SQL DDL and SQL DML keywords. |
|
|
|
|
|
|
|
|
· Display any result sets created by the SQL statements (SELECT_FROM) in data grids that can be reviewed by the user. To keep the project relatively simple, allow users to only view the results of queries, not update them. |
|
|
|
|
|
|
|
|
· Provide an MDI interface so that more than one result set can be viewed at a time. |
|
|
|
|
|
|
|
|
· Provide a VBA-compliant object model interface so that SQL-VB5 can be called from within other programs. |
|
|
|
|
|
|
|
|
· Provide the ability to read an MDB file and generate a valid SQL-VB5 script to re-create the database structure, including all tables, indexes, and relationships. |
|
|
|
|
|
|
|
|
· Provide a simple About box to display program information. |
|
|
|
|
|
|
|
|
· Provide direct access to editing SQL script files without having to exit the SQL-VB5 program. |
|
|
|
|
|
|
|
|
· Allow users to add comment lines in the SQL-VB5 script for documentation purposes. |
|
|
|
|
|
|
|
|
· Provide reasonable error trapping and reporting to aid in debugging SQL scripts. |
|
|
|
|
|
|
|
|
· Allow users to open any Microsoft Jet-supported database format and allows users to create new Microsoft Jet-format databases. |
|
|
|
|
|
|
|
|
That last item may be a surprise to some. Remember that Microsoft Access SQL has no keyword for opening, closing, or creating a database! You add your own script keywords to handle this. |
|
|
|
|
|